<tagLib name="fanwe" />
<include file="Public:header" />
<form method="post" id="myform" name="form" action="/admin/index.php?a=add&m=WoguProducts" style="width: 1208px;">
    <table cellpadding="4" cellspacing="0" border="0" class="table-form">
        <tbody>
            <tr>
                <th class="first" width="100">栏目</th>
                <td>
                    <fanwe:select id='parent_id' name='parent_id' first='请选择' selected="vo['parent_id']" textfield='cate_name' valuefield='cate_id' options='cate_list' />
                </td>
            </tr>
            <tr>
                <th class="first">产品名称</th>
                <td><input type="text" class="textinput" name="title"></td>
            </tr>
            <tr>
                <th class="first">价格</th>
                <td><input type="text" class="textinput" name="price"></td>
            </tr>
            <tr>
                <th class="first">定金</th>
                <td>
                    <select name="dj">
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="first">图片地址</th>
                <td><input type="text" class="textinput" name="img"></td>
            </tr>
            <tr>
                <th class="first">图片宽度</th>
                <td><input type="text" class="textinput" size="50" name="width" placeholder="仅需在获取图片尺寸失败时填写"></td>
            </tr>
            <tr>
                <th class="first">图片高度</th>
                <td><input type="text" class="textinput" size="50" name="height" placeholder="仅需在获取图片尺寸失败时填写"></td>
            </tr>
            <tr>
                <th class="first">旗舰店</th>
                <td><select name="is_qjd">
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select></td>
            </tr>
            <tr>
                <th class="first">来源</th>
                <td>
        		    <select name="source">
        		        <option value="cj">cj</option>
        		        <option value="亚马逊">亚马逊</option>
        		        <option value="京东">京东</option>
        		        <option value="淘宝">淘宝</option>
                        <option value="天猫">天猫</option>
        		    </select>
                </td>
            </tr>
            <tr>
                <th class="first">跳转地址</th>
                <td><input type="text" class="textinput" name="redirecturl"></td>
            </tr>
            <tr>
                <th class="first">排序</th>
                <td><input type="text" class="textinput" name="orderby" value="0"></td>
            </tr>
            <tr>
                <th class="first">产品描述</th>
                <td><textarea name="content" style="margin: 0px; width: 579px; height: 257px;"></textarea></td>
            </tr>
            <tr class="act">
                <th class="first">&nbsp;</th>
                <td>
                    <input type="button" onclick="getimgsize()" class="submit_btn" value="提交">&nbsp;&nbsp;
			        <input type="reset" class="reset_btn" value="重置">
			    </td>
			</tr>
	    </tbody>
	</table>
	<input type="hidden" name="doadd" value="1"/>
</form>
<include file="Public:footer" />
<script type="text/javascript" charset="utf-8" src="/public/js/jquery.form.min.js"></script>
<script type="text/javascript">
function resetform() {
    $('input[name="title"]').val('');
    $('input[name="price"]').val('');
    $('input[name="redirecturl"]').val('');
    $('textarea[name="content"]').val('');
}

$('#myform').submit(function(){
    $(this).ajaxSubmit({
        success: function(s) {
        	if(s == 'ok') {
        	    alert('ok');
        	    resetform();
        	}
        },
        error: function() {}
    });
    return false;
});

function getimgsize() {
    var img = $('input[name="img"]').val();
    if('' == img) {
        alert('请填写图片地址');
        return;
    }
    
    var url = '/admin/index.php?a=add&m=WoguProducts&op=getimgsize&img='+encodeURIComponent(img);
    if(img[0] == '/')
        url += '&host=' + location.host;
    $.get(url, function(s) {
        if(s == '0') {
            alert('图片尺寸获取失败，请手动填入！');
        } else {
            var arr = s.split('|');
            $('input[name="width"]').val(arr[0]);
            $('input[name="height"]').val(arr[1]);
            window.setTimeout(function(){
                $('#myform').submit();
            }, 1000);
        }
    })
}
</script>